<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2010. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<title> Viewing the type hierarchy</title>
<link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css">
<script language="JavaScript" type="text/javascript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js"> </script>
</head>
<body>
<h1>Viewing the type hierarchy</h1>
<p> In this section, you will learn about using the Type Hierarchy view by viewing
classes and members in a variety of different ways. </p>
<ol>
  <li> In the Package Explorer view, find <em>junit.framework/TestCase.java</em>. 
    From its context menu, select
    <a class="command-link" href='javascript:executeCommand("org.eclipse.jdt.ui.commands.showElementInTypeHierarchyView(elementRef=JUnit/junit.framework.TestCase)")'>
    <img src="PLUGINS_ROOT/org.eclipse.help/command_link.svg" alt="Open type hierarchy">
    <strong>Open Type Hierarchy</strong></a>.
    You can also open type hierarchy view: 
    <ul>
      <li> from the menu bar by selecting <strong>Navigate &gt; Open Type 
        Hierarchy</strong>.</li>
      <li> from the keyboard by pressing <kbd>F4</kbd> after selecting <em>TestCase.java</em>. 
      </li>
    </ul>
	<p>
    <img src="images/view_package_explorer_open_type_hierarchy.png"  alt="Context menu">
	</p>
  </li>
  <li> The buttons in the view tool bar control which part of the hierarchy is
    shown.&nbsp; Click the&nbsp;<strong>Show the Type Hierarchy&nbsp;</strong>button 
    to see the class hierarchy, including the base classes and subclasses. The 
    small arrow on the left side of the type icon of TestCase indicates that the 
    hierarchy was opened on this type.
	<p>
    <img src="images/view_typehierarchy_testcase_small.png"  alt="Type Hierarchy"> 
	</p>
  </li>
  <li> Click the <strong>Show the Supertype Hierarchy</strong> button to 
    see a hierarchy showing the type's parent elements including implemented
    interfaces. This view shows the results of going up the type hierarchy.
	<p>
    <img src="images/view_typehierarchy_testcase_supertype.png"  alt="Supertype hierarchy"> 
	</p>
    In this &quot;reversed hierarchy&quot; view, you can see that TestCase implements 
    the Test interface. </li>
  <li> Click the&nbsp;<strong>Show the Subtype Hierarchy</strong> button in the 
    view toolbar.
	<p>
    <img src="images/view_typehierarchy_testcase_subtype.png"  alt="Subtype hierarchy"> 
	</p>
  </li>
  <li> Click the <strong>Lock View and Show Members in Hierarchy</strong> 
    button in the toolbar of the member pane, then select the runTest() method 
    in the member pane. The view will now show all the types implementing runTest(). 
	<p>
    <img src="images/view_typehierarchy_testcase_runtest_locked.png"  alt="Subtype hierarchy showing method implementors"> 
	</p>
  </li>
  <li> In the Type Hierarchy view, click the <strong>Show the Supertype Hierarchy</strong> 
    button. Then on the member pane, select <code>countTestCases()</code> to display 
    the places where this method is declared.
	<p>
    <img src="images/view_typehierarchy_testcase_supertype_locked.png"  alt="Supertype hierarchy showing method implementors"> 
	</p>
  </li>
  <li> In the Type Hierarchy view select the <em>Test</em> element and select <strong>Focus 
    On 'Test'</strong> from its context menu. <em>Test</em> is presented in the Type Hierarchy view. </li>
  <li> Activate the Package Explorer view and select the package junit.framework. 
    Use <strong>Open Type Hierarchy</strong> from its context menu. A hierarchy 
    is opened containing all classes of the package. For completion of the tree, 
    the hierarchy also shows some classes from other packages. These types are 
    shown by a type icon with a white fill.
	<p>
    <img src="images/view_typehierarchy_testcase_focused.png"  alt="Hierarchy on a package"> 
	</p>
  </li>
  <li> Use <strong>Previous Type Hierarchies</strong> to go back to a previously 
    opened element. Click on the arrow next to the button to see a list of elements or click 
    on the button to edit the history list.
	<p>
    <img src="images/view_typehierarchy_testcase_menu.png"  alt="History menu"> 
	</p>
  </li>




</ol>
<p><a name="quick_type_hierarchy"></a>
If you are working in the editor and only want to do a quick lookup for a hierarchy you can use the
<strong>Quick Type Hierarchy</strong>:</p>
<ol>
<li>Open 
<em>junit.framework.TestCase.java</em> file in the Java editor 
if you do not already have it open.</li>
<li>Select the type name in the Java editor</li>
<li>Press <kbd>Ctrl+T</kbd> or invoke <strong>Navigate &gt; Quick Type Hierarchy</strong> and the
in-place type hierarchy view is shown.</li>

<li>Pressing <kbd>Ctrl+T</kbd> while the type hierarchy view is shown will toggle between 
supertype hierarchy and subtype hierarchy.</li>
</ol>
<img src="images/quicktype_dialogs.png" alt="Quicktype dialogs showing subtype and supertype hierarchy">
<p>
To see where a virtual method call can resolve to:
</p>
<ol>
<li>In the body of <em>runBare()</em> select the invocation of
<em>setUp()</em></li>
<li>Press <kbd>Ctrl+T</kbd> or invoke <strong>Navigate &gt; Quick Type Hierarchy</strong> and the
in-place type hierarchy view is shown.</li>
<li>You can see that <em>setUp()</em> is implemented in 3 more classes. <em>Object</em> and <em>Assert</em> are
only shown with a white filled images as are only required to complete the hierarchy but do not implement <em>setUp()</em></li>
<li>Select a type to navigate to its implementation of <em>setUp()</em></li>
</ol>
<img src="images/quicktype_dialog_setup.png" alt="Quicktype dialog showing types that implement setUp()">





<P class="nav_footer" id="nav_footer">Next Section: <A href="qs-11.htm">Searching the workbench</A>
</P>

<h3 class="related">Related concepts</h3> 
  <a href="../concepts/concept-java-editor.htm">Java views</a>

<h3 class="related">Related references</h3> 
  <a href="../reference/views/ref-type-hierarchy.htm">Type Hierarchy view</a><br>
  <a href="../reference/preferences/ref-preferences-java.htm">Java Base preference page</a> 

</body>
</html>

